/*********************************************************************************
 *      Copyright:  (C) 2020 Juan
 *                  All rights reserved.
 *
 *       Filename:  libevent_server1.c
 *    Description:  This file 
 *                 
 *        Version:  1.0.0(28/07/20)
 *         Author:  wangruijie <1046299465@qq.com>
 *      ChangeLog:  1, Release initial version on "28/07/20 08:19:22"
 *                 
 ********************************************************************************/
#include "server.h"

int main(int argc, char **argv)
{
    int                    SERVER_PORT;   //端口信息
    char                   *progname = NULL;
    int                    opt;

    /* 参数解析 */
    struct option            long_options[]=
    {
        {"port", required_argument, NULL, 'p'},
        {"help", no_argument, NULL, 'h'},
        {NULL, 0, NULL, 0}
    };

    progname = basename(argv[0]);

    while((opt = getopt_long(argc,argv,"p:h",long_options,NULL))!=-1)
    {
        switch(opt)
        {
            case 'h':
                print_usage(progname);
                return EXIT_SUCCESS;

            case 'p':
                SERVER_PORT = atoi(optarg);
                break;

            default:
                break;
        }
    }

    if(!SERVER_PORT)
    {
        print_usage(argv[0]);
        return 0;
    }

    run_server(SERVER_PORT);

    return 0;
}

